<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    .main {
        padding: 1rem;
        background-color: #fff;
    }

    .item {
        width: 100%;
        /* height: 7.5rem; */
        box-shadow: 0 0.1rem 0.5rem 0.1rem #eee;
        margin-bottom: 1rem;
        border-radius: 1rem;

    }

    .item div {
        padding: 0.8rem;
        font-size: 0.6rem;
        color: #838383;
    }

    .item div .item_title {
        font-size: 0.7rem;
        color: #303030;
    }

    .item div .item_title span {
        margin-left: 1rem;
    }

    .item .symptom {
        font-size: 0.7rem;
        color: #303030;
        margin-top: 0.5rem;
    }

    .item .prescription {
        margin: 0.25rem 0 0.75rem 0;
    }

    /* .item .chat {
        float: right;
        color: #2E8EFF;
        width: 2.5rem;
        height: 1rem;
        background-color: #F2F2F2;
        font-size: 0.5rem;
        text-align: center;
        line-height: 1.1rem;
        border-radius: 0.2rem;
        margin-top: -0.9rem;
    } */

    .yianjia {
        width: 100%;
        box-shadow: 0 0.1rem 0.5rem 0.1rem #eee;
        margin-bottom: 1rem;
        border-radius: 1rem;
    }

    .yianjia div {
        padding: 0.8rem;
        font-size: 0.6rem;
        color: #838383;
    }

    .yianjia div .item_title span {
        margin-left: 1rem;
    }

    .yianjia .symptom {
        font-size: 0.7rem;
        color: #303030;
    }

    .yianjia .prescription {
        margin: 0.25rem 0 0.25rem 0;
    }

    .new {
        width: 100%;
        height: 2.2rem;
        color: #fff;
        text-align: center;
        line-height: 2.2rem;
        font-size: 0.8rem;
        background-color: #FD6151;
        position: fixed;
        bottom: 0;
        left: 0;
    }

    .icon_search {
        position: absolute;
        width: 0.7rem;
        height: 0.7rem;
        top: 1.85rem;
        left: 6.2rem;
    }

    .search_input {
        text-align: center;
        background-color: #e8e8e8;
        color: #565656;
        font-size: 0.6rem;
        height: 1.5rem;
        line-height: 1.5rem;
        width: 75%;
        padding-left: 5%;
        margin: 0 10% 1rem 10%;
        border-radius: 0.2rem;

    }

    .search_input::-webkit-input-placeholder {
        color: #fff;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>

        <div class="gerenyian main" v-if="gerenyian == 0">

            <img class="icon_search" v-if="icon_search" src="../image/icon_search_white.png" alt="">
            <input type="text" class="search_input" v-model="search_yian" placeholder="搜索医案">

            <div class="item" v-for="item in yian_list">
                <div>
                    <p class="item_title">{{item.name}}
                        <span v-if="item.sex == 1">男</span>
                        <span v-else>女</span>
                        <span>{{item.age}}岁</span>
                    </p>
                    <!-- <p class="chat">发起沟通</p> -->
                    <p class="symptom">{{item.diseases}}</p>
                    <p class="prescription">{{item.remark}}</p>
                    <p class="time">{{item.createTime}}</p>
                </div>

            </div>
            <p class="last_title">已经没有更多了~</p>

            <div class="new openwin" data-win="new_yian_win">新建医案</div>
            <div style="height: 2.2rem;width: 100%;"></div>
        </div>

        <div class="main" v-else>
            <img class="icon_search" v-if="icon_search" src="../image/icon_search_white.png" alt="">
            <input type="text" class="search_input" v-model="search_input" placeholder="搜索病症、人名等">
            <div class="yianjia" @click="go_person_consilia_yianjia_win('2271684996871102471')">
                <div>
                    <p class="symptom">默认医案夹</p>
                    <p class="prescription">0份医案</p>
                </div>
            </div>

            <!-- 渲染数据 -->
            <!-- <div class="yianjia" v-for="item in yianjia_list" @click="go_person_consilia_yianjia_win(item.id)"
                :data-title="item.name">
                <div>
                    <p class="symptom">{{item.name}}</p>
                    <p class="prescription">{{item.remark}}</p>
                </div>
            </div> -->


            <p class="last_title">已经没有更多了~</p>
            <div class="new openwin" data-win="new_yianjia_win">新建医案夹</div>
            <div style="height: 2.2rem;width: 100%;"></div>
        </div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();

        // 接收win传过来的区分标识
        api.addEventListener({
            name: 'qieTab'
        }, function (ret, err) {
            if (ret) {
                app.gerenyian = ret.value.val
                app.$nextTick(function () {
                    hb_init_openwinby_click();
                })
            }
        });
        api.addEventListener({
            name: 'baocun_yian'
        }, function (ret, err) {
            if (ret) {
                yianjia_list() // 请求医案夹列表
                yian_list() // 请求医案列表
            }
        })

        yianjia_list() // 请求医案夹列表
        yian_list() // 请求医案列表
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            gerenyian: 0, // 区分标识
            search_input: "", // 搜索内容
            icon_search: true, //搜索图标的显示
            search_yian: "",
            page: 1, // 分页的页数
            yianjia_list: [], // 医案夹列表数据
            yian_list: [], // 医案列表数据
        },
        methods: {
            // 去到医案夹里面
            go_person_consilia_yianjia_win: function (id) {
                api.openWin({
                    name: "person_consilia_yianjia_win",
                    url: "person_consilia_yianjia_win.html",
                    pageParam: {
                        id: id
                    }
                })
            }
        },
        watch: {
            search_input: function (val) {
                if (val) {
                    this.icon_search = false
                } else {
                    this.icon_search = true
                }
            },
            search_yian: function (val) {
                if (val) {
                    this.icon_search = false
                } else {
                    this.icon_search = true
                }
            }
        },

    })



    // 请求医案夹列表
    function yianjia_list() {
        get_ajax("medicalfolder/listpage", {
            userid: "2270594831092129792",
            page: app.page,
            pagesize: 10,
        }, function (ret, err) {
            if (ret.code == 200) {
                app.yianjia_list = ret.data.data
            } else {
                toast("请求数据异常，请稍后再试！")
            }
            if (err) {
                alert("网络不通畅，请稍后再试！")
            }
        })
    }


    // 请求医案列表
    function yian_list() {
        get_ajax("medical/listpage", {
            userid: $api.getStorage("emp").userId,
            folderid: 1,
            page: app.page,
            pagesize: 10,
        }, function (ret, err) {
            if (ret.code == 200) {
                app.yian_list = ret.data.data
            } else {
                toast("请求数据异常，请稍后再试！")
            }
            if (err) {
                alert("网络不通畅，请稍后再试！")
            }
        })
    }
</script>